@extends('admin.base')

@section('content')
    <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief" style="">
        <ul class="layui-tab-title">
            <li class="layui-this">发送短信</li>

        </ul>
        <div class="layui-card layui-tab-content" style="">
            <div class="layui-card-body layui-tab-item layui-show">

                <div class="layui-form-item">
                    <label for="" class="layui-form-label">群发手机号(多个手机号逗号,分隔)</label>
                    <div class="layui-input-block">
                        <!--<input type="text" name="title" value="" lay-verify="required" placeholder="请输入标题"
                               class="layui-input">  -->

                        <input type="text" name="title" value="" id="phone" placeholder="请输入群发手机号"
                               class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label for="" class="layui-form-label">群发内容</label>
                    <div class="layui-input-block">
                            <textarea id="msg" class="layui-textarea" name="description" cols="30" rows="3"
                            ></textarea>
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" id="sendMsg" lay-filter="formDemo">发 送</button>
                    </div>
                </div>

            </div>

        </div>
    </div>
@endsection

@section('script')
    <script type="text/javascript">
        $('body').on('click', '#sendMsg', function () {

            var phone = $("#phone").val();
            var msg = $("#msg").val();
            if (phone.length <= 1) {
                layer.msg("手机号必须填写");
                return false;
            }
            phone = phone.replace("，", ",");
            var preg = /^1[3578][0-9]{9}(,1[3578][0-9]{9})*$/;
            var arr_count = phone.match(preg);
            if (arr_count == null) {
                layer.msg("手机号格式有误", {icon: 5});
                return false;
            }
            if (msg.length <= 1) {
                layer.msg("发送消息必须填写", {icon: 5});
                return false;
            }
            $.post('/sendmany', {'phone': phone, 'msg': msg}, function (data) {
                layer.msg(data.msg, {icon: 6});
            }, 'json')
        })
        ;
    </script>
@endsection()

